<!--************************************************************************************************-->
<!-- < loginResult.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Modifier: Xiaoxin Mo                                                                 -->
<!-- Stu : 10389159                                                                                 -->
<!-- Date: 2012-12-23                                                                               -->
<!-- Modifier: Xiaofen Huang                                                                 -->
<!-- Stu : 10389169                                                                                 -->
<!-- Date: 2013-1-8                                                                            -->
<!-- Destription :    改变样式(result.css)                                                    -->
<!--                                                                                                -->
<!-- Version : 2.0                                                                                  -->
<!--************************************************************************************************-->

<!DOCTYPE html>
<?php
	@session_start();
	include_once("../manager/UserManager.php");
	include_once("../db/User.php");
	//include_once("bottom.php");
?>
<html lang="zh-hk">
	<?php
	$username = $_POST['username'];
	$password = $_POST['password'];
	
	$flag = 0;
	if( $username != "") {
		$correct_password = UserManager::getInstance()->getPasswordByUsername($username);
		$UserID = UserManager::getInstance()->getIDByUsername($username);
		
		if ($password === $correct_password)
		{
			// 获得当前登陆的用户，以便后面的页面得到当前登录的用户
			
			$_SESSION['currentUser'] = $username;
			$_SESSION['currentID'] = $UserID;
		}
		else
			$flag = 1;
	}
	else
		$flag = 1;
	?>
	
	<head>
		<title>TINY bOOk</title>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
		<meta name="contentType" value="text/html  charset=GBK">
		<link rel="stylesheet" type="text/css" href="../css/result.css"/>
		<link rel="shortcut icon" href="images/shortcut.jpg"/>
		
		<?php
			if ($flag === 0)
			{
				if ($username === "manager")
				{
		?>
					<meta http-equiv="refresh" content="1; url=adminPage.php">
		<?php
				}else
				{
				?>
					<meta http-equiv="refresh" content="1; url=mainPage.php">
				<?php
				}
			}
		?>
		
	</head>	
		
	<body>
		<div id="title" class="banner">
			<h1>TINY bOOk</h1>
		</div>
		<div id="welcome">
			<h2>欢迎成为TINY bOOk的成员</h2>
		</div>

		<div id="hasRegister">
			<?php
				if ($flag === 0)
				{
			?>
				<p>已登陆，跳转到主页面</a></p>
			<?php
				}
				else
				{
			?>
				<p>用户名或密码不正确</a></p>
			<?php
				}
			?>
			
		</div>
	</body>
</html>